def min_add_to_match_parentheses(s: str, left_char="(", right_char=")"):
    result = 0
    left_rest_count = 0
    for c in s:
        if c == left_char:
            left_rest_count += 1
            continue
        if c == right_char:
            if left_rest_count > 0:
                left_rest_count -= 1
            else:
                result += 1
    return result + left_rest_count


def _main():
    input_str: str = input()
    print(min_add_to_match_parentheses(input_str))


if __name__ == "__main__":
    _main()
